package com.example.weiting.huishenghuo.com.example.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.example.weiting.huishenghuo.R;
import com.example.weiting.huishenghuo.utils.User;

import java.io.Serializable;
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    ArrayList<User> users = new ArrayList<User>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //测试数据
        User user = new User("root","root");
        users.add(user);
        //获取登陆按钮，并跳转到登陆界面
        Button degnLu = (Button) findViewById(R.id.dengLu);
        degnLu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //将userList传送到登陆页面。
                Intent intent = new Intent(MainActivity.this, Login.class);
                Bundle args = new Bundle();
                args.putSerializable("userList",(Serializable)users);
                intent.putExtra("users",args);
                startActivity(intent);
            }
        });
        //获取注册按钮，并跳转到注册页面
        Button zhuCe = (Button) findViewById(R.id.zhuCe);
        zhuCe.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //将userList传送到注册页面。
                Intent intent = new Intent(MainActivity.this, Register.class);
                Bundle args = new Bundle();
                args.putSerializable("userList",(Serializable)users);
                intent.putExtra("users",args);
                startActivity(intent);
            }
        });

    }
}
